package example.single.service;

import blingking.jfinal.orm.annotation.JFinalORMTx;
import com.jfinal.plugin.activerecord.Db;
import example.single.model.Torder;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class OrderService {

    public boolean addOrder(){

        Torder torder = new Torder();
        torder.setGoodsId(2);
        torder.setOrderNum("222222");
        torder.setAmount(new BigDecimal("222"));
        return torder.save();
    }

    @JFinalORMTx
    public boolean addOrderTx(){
        Db.template("addOrder",new BigDecimal("111"),1,"1111").update();

        Db.template("addOrder2",new BigDecimal("333"),3,"3333").update();


        Torder torder = new Torder();
        torder.setGoodsId(2);
        torder.setOrderNum("222222");
        torder.setAmount(new BigDecimal("222"));
        torder.save();

        Torder torder2 = new Torder();
        torder2.setGoodsId(2);
        torder2.setOrderNum("222222");
        torder2.setAmount(new BigDecimal("222"));
        boolean bool = torder2.save();
        return bool;
    }
}
